package com.sesame;

import kim.sesame.common.web.context.SpringContextUtil;
import kim.sesame.framework.web.init.WebInit;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.web.cors.CorsConfiguration;

@ServletComponentScan(basePackageClasses = WebInit.class)
@SpringBootApplication
public class AppCasServer {

    public static void main(String[] args) {
        SpringApplication.run(AppCasServer.class, args);
        

    }

    /**
     * 跨域
     * @return
     */
//    @Bean
//    public CorsFilter corsFilter() {
//        UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
//        source.registerCorsConfiguration("/**", buildConfig()); // 4
//        return new CorsFilter(source);
//    }

    private CorsConfiguration buildConfig() {
        CorsConfiguration corsConfiguration = new CorsConfiguration();
        corsConfiguration.addAllowedOrigin("*"); // 1
        corsConfiguration.addAllowedHeader("*"); // 2
        corsConfiguration.addAllowedMethod("*"); // 3
        return corsConfiguration;
    }



}
